﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Digitalmes.Model.WmsManagement;
using Digitalmes.Model;

namespace Digitalmes.ViewModel.WmsManagement.OutboundSheetVMs
{
    public partial class OutboundSheetListVM : BasePagedListVM<OutboundSheet_View, OutboundSheetSearcher>
    {
        
        protected override IEnumerable<IGridColumn<OutboundSheet_View>> InitGridHeader()
        {
            return new List<GridColumn<OutboundSheet_View>>{
                
                this.MakeGridHeader(x => x.OutboundSheet_Code).SetTitle(@Localizer["Page.出库单号"].Value),
                this.MakeGridHeader(x => x.OutboundSheet_Desc).SetTitle(@Localizer["Page.出库说明"].Value),
                this.MakeGridHeader(x => x.OutboundSheet_StoretakeDate).SetTitle(@Localizer["Page.出库时间"].Value),
                this.MakeGridHeader(x => x.OutboundSheet_Status).SetTitle(@Localizer["Page.状态"].Value),
                this.MakeGridHeader(x => x.OutboundSheet_CreateTime).SetTitle(@Localizer["_Admin.CreateTime"].Value),
                this.MakeGridHeader(x => x.OutboundSheet_UpdateTime).SetTitle(@Localizer["_Admin.UpdateTime"].Value),
                this.MakeGridHeader(x => x.OutboundSheet_CreateBy).SetTitle(@Localizer["_Admin.CreateBy"].Value),
                this.MakeGridHeader(x => x.OutboundSheet_UpdateBy).SetTitle(@Localizer["_Admin.UpdateBy"].Value),

                this.MakeGridHeaderAction(width: 200)
            };
        }

        
        public override IOrderedQueryable<OutboundSheet_View> GetSearchQuery()
        {
            var query = DC.Set<OutboundSheet>()
                
                .CheckContain(Searcher.Code, x=>x.Code)
                .CheckContain(Searcher.Desc, x=>x.Desc)
                .CheckContain(Searcher.StoretakeDate, x=>x.StoretakeDate)
                .CheckEqual(Searcher.Status, x=>x.Status)
                .CheckBetween(Searcher.CreateTime?.GetStartTime(), Searcher.CreateTime?.GetEndTime(), x => x.CreateTime, includeMax: false)
                .CheckBetween(Searcher.UpdateTime?.GetStartTime(), Searcher.UpdateTime?.GetEndTime(), x => x.UpdateTime, includeMax: false)
                .CheckContain(Searcher.CreateBy, x=>x.CreateBy)
                .CheckContain(Searcher.UpdateBy, x=>x.UpdateBy)
                .Select(x => new OutboundSheet_View
                {
				    ID = x.ID,
                    
                    OutboundSheet_Code = x.Code,
                    OutboundSheet_Desc = x.Desc,
                    OutboundSheet_StoretakeDate = x.StoretakeDate,
                    OutboundSheet_Status = x.Status,
                    OutboundSheet_CreateTime = x.CreateTime,
                    OutboundSheet_UpdateTime = x.UpdateTime,
                    OutboundSheet_CreateBy = x.CreateBy,
                    OutboundSheet_UpdateBy = x.UpdateBy,
                })
                .OrderBy(x => x.ID);
            return query;
        }

        
    }
    public class OutboundSheet_View: OutboundSheet
    {
        
        public string OutboundSheet_Code { get; set; }
        public string OutboundSheet_Desc { get; set; }
        public string OutboundSheet_StoretakeDate { get; set; }
        public FormStatusEnum? OutboundSheet_Status { get; set; }
        public DateTime? OutboundSheet_CreateTime { get; set; }
        public DateTime? OutboundSheet_UpdateTime { get; set; }
        public string OutboundSheet_CreateBy { get; set; }
        public string OutboundSheet_UpdateBy { get; set; }

    }

}